package com.xian.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.manage.domain.Playground;
import com.xian.manage.service.IPlaygroundService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 建筑艺术Controller
 * 
 * @author Hanys
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/manage/playground")
public class PlaygroundController extends BaseController
{
    @Autowired
    private IPlaygroundService playgroundService;

    /**
     * 查询建筑艺术列表
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:list')")
    @GetMapping("/list")
    public TableDataInfo list(Playground playground)
    {
        startPage();
        List<Playground> list = playgroundService.selectPlaygroundList(playground);
        return getDataTable(list);
    }

    /**
     * 导出建筑艺术列表
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:export')")
    @Log(title = "建筑艺术", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Playground playground)
    {
        List<Playground> list = playgroundService.selectPlaygroundList(playground);
        ExcelUtil<Playground> util = new ExcelUtil<Playground>(Playground.class);
        util.exportExcel(response, list, "建筑艺术数据");
    }

    /**
     * 获取建筑艺术详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(playgroundService.selectPlaygroundById(id));
    }

    /**
     * 新增建筑艺术
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:add')")
    @Log(title = "建筑艺术", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Playground playground)
    {
        return toAjax(playgroundService.insertPlayground(playground));
    }

    /**
     * 修改建筑艺术
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:edit')")
    @Log(title = "建筑艺术", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Playground playground)
    {
        return toAjax(playgroundService.updatePlayground(playground));
    }

    /**
     * 删除建筑艺术
     */
    @PreAuthorize("@ss.hasPermi('manage:playground:remove')")
    @Log(title = "建筑艺术", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(playgroundService.deletePlaygroundByIds(ids));
    }
}
